#pragma once


#include<vector>


void swap1(int& a, int& b)
{
	int tmp = a;
	a = b;
	b = tmp;
}

void SelectSort(std::vector<int>& nums)
{
	int n = nums.size();
	int left = 0, right = n - 1;
	while (left < right)
	{
		int mini = left, maxi = left;
		for (int i = left + 1; i <= right; i++)
		{
			if (nums[mini] > nums[i])
			{
				mini = i;
			}

			if (nums[maxi] < nums[i])
			{
				maxi = i;
			}
		}

		swap1(nums[mini], nums[left]);

		if (maxi == left)
		{
			maxi = mini;
		}

		swap1(nums[maxi], nums[right]);
		left++;
		right--;
	}
}